<template>
  <view class="doctor">
    <!--    tab-->
    <view class="doctortab">
      <view class="doctorOne" style=" border: 1px solid #f9f9f9;" :class="key===-1?'a':''" @click="tabAll">全部</view>
      <scroll-view scroll-x="true" class="scroll-box">
        <view class="doctorbox">
          <view style=" display: flex;">
            <view class="doctorOne" v-for="(item,index) in timelst" :key="index" @click="tab(item,index)">
              <view class="da1">{{ item.date }}</view>
              <view class="da1" :class="index===key?'a':''">{{ item.week }}</view>
              <view class="da1">{{ item.nu_source === 0 ? '无号' : '可约' }}</view>
            </view>
          </view>
        </view>
      </scroll-view>

    </view>
    <!--    内容-->
    <view class="box">
      <view class="box1" v-for="(item,index) in alldlist" :key="index">
        <image :src="item.avatar"></image>
        <view class="txt">
          <view class="txt2">{{ item.name }}</view>
          <view class="txt1">{{ item.post }}</view>
          <view class="txt1">{{ item.good_at }}</view>
        </view>
        <button @click="go(item._id)">预约</button>
      </view>
      <nullList name="当日没有医生排班" v-if="alldlist.length===0"></nullList>
    </view>
  </view>
</template>

<script>
import {
  everydlist,
  getalldlist,
  gettimesele
} from "utils/API/registation";
import nullList from "../../components/nullList/nullList.vue"

export default {
  components: {
    nullList
  },
  data() {
    return {
      alldlist: [],
      timelst: [],
      key: -1,
      obj: {
        dep_id: '',
        week: ""
      }
    };
  },
  async onLoad({id}) {
    this.xuan(id)
    this.xuan1(id)
  },
  methods: {
    //全部的
    async xuan(id) {
      let {data} = await getalldlist(id)
      this.alldlist = data;
    },
    //时间的
    async xuan1(id) {
      let {data} = await gettimesele(id)
      this.timelst = data;
    },
    //点击时间
    async tab(item, index) {
      this.key = index
      let {data} = await everydlist({dep_id: item.dep_id, week: item.date})
      this.alldlist = data;
    },
    //点击全部
    tabAll() {
      this.key = -1
    },
    go(id){
      wx.navigateTo({
        url:'/pages/doctorhome/doctorhome?id='+id
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.a {
  color: #6fa5fe;
}

.box {
  width: 100%;
  margin-top: 10px;
  //height:;
  .box1 {
    width: 100%;
    height: 120px;
    background-color:#fff;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;

    image {
      width: 90px;
      height: 90px;
      border-radius: 50%;
    }
    button{
      border: 1px solid #2c8dff;
      background-color: #fff;
      border-radius: 30px;
      height: 30px;
      line-height: 30px;
      color: #2c8dff;
      font-size: 14px;
      margin-right: 15px;
    }
    .txt {
      width: 200px;
      height: 100px;
      line-height: 30px;
      padding-left: 5px;

      .txt1 {
        width: 200px;
        font-size: 14px;
        color: #bcbdbe;
        white-space: nowrap; /* 不换行 */
        overflow: hidden; /* 超出隐藏 */
        text-overflow: ellipsis; /* 超出部分显示省略号 */
      }

      .txt2 {
        font-weight: bold;
        font-size: 20px;
      }
    }
  }
}

.scroll-box {
  white-space: nowrap;
  height: 100%;
  width: 300px;
}

.scroll-box .doctorbox {

  box-sizing: border-box;
  display: inline-block;

}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 200rpx;
  color: #858585;
}

.point image {
  display: block;
  width: 230rpx;
  height: 230rpx;
}

.doctor {
  width: 100%;
  height: 100%;
  background-color: #f7f7f7;

  .doctortab {
    width: 100%;
    height: 100px;
    background-color: #ffffff;
    display: flex;


    .doctortwo {
      width: 375px;
      //background-color: #4cd964;
      height: 100%;
      //display: flex;
    }
  }
}

.doctorOne {
  width: 70px !important;
  height: 100% !important;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;

  .da1 {
    height: 33px !important;
    line-height: 33px;
  }
}
</style>
